package com.wrupple.muba.catalogs.client.activity.process.state.impl;

import java.util.List;

import com.google.inject.Inject;
import com.google.inject.Provider;
import com.wrupple.muba.catalogs.client.activity.CatalogActivity;
import com.wrupple.muba.catalogs.client.activity.process.CatalogTypeSelectionProcess;
import com.wrupple.muba.catalogs.client.activity.process.LoadSelectionProcessData;
import com.wrupple.muba.catalogs.domain.CatalogPlace;
import com.wrupple.muba.catalogs.domain.CatalogProcessDescriptor;
import com.wrupple.muba.common.domain.DesktopPlace;

public class LoadSelectionProcessDataImpl extends AbstractCatalogProcessDescriptorLoadingState<DesktopPlace,List<CatalogPlace>> implements LoadSelectionProcessData {
	
	@Inject
	public LoadSelectionProcessDataImpl(Provider<CatalogTypeSelectionProcess> provider) {
		super(provider);
	}

	@Override
	protected void setValue(CatalogProcessDescriptor parameter,
			List<CatalogPlace> result) {
		String catalog = result.get(0).getProperty(CatalogActivity.CATALOG_ID_PARAMETER);
		parameter.setSelectedType(catalog );		
	}

	@Override
	protected DesktopPlace generateWrappedProcessInput() {
		return super.context.getDesktopManager().getWhere();
	}
	@Override
	protected boolean testCurrentState(CatalogProcessDescriptor parameter) {
		return parameter.getSelectedType()==null;
	}

}
